﻿Imports SIGI.Common.CommonDefinitions

Public Class UC_ABMBase

#Region "<< -Attributes- >>"
    Protected _MsgBox As frmMessage = New frmMessage()
    Protected _Behavior As CRUD = CRUD.Read
    Protected _Screen As Common.CommonDefinitions.Screen = Common.CommonDefinitions.Screen.Unknown
#End Region

#Region "<< -Properties- >>"
    Public WriteOnly Property Screen As Common.CommonDefinitions.Screen
        Set(value As Common.CommonDefinitions.Screen)
            _Screen = value
        End Set
    End Property
#End Region

#Region "<< -Events- >>"
    Private Sub UC_ABMBase_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        If Me.DesignMode Then Return

        Dim wScreenController As ScreenController = Nothing
        Dim wPermission As Permission = Permission.Unknown
        Dim wIdPermission As Integer = 0
        Dim wIdProfile As Integer = 0
        Try
            If Me.DesignMode Then Return

            'Verifico los permisos de ABM de la pantalla
            If _Screen = Common.CommonDefinitions.Screen.Unknown Then Return

            wIdProfile = GlobalVariables.gLoguedUser.Profile.Id
            wScreenController = New ScreenController
            wIdPermission = wScreenController.SearchScreenPermissionByProfile(wIdProfile, _Screen)
            wPermission = DirectCast(wIdPermission, Permission)
            If wPermission = Permission.ReadAndWrite Then
                btnNew.Enabled = True
                btnUpdate.Enabled = True
                btnDelete.Enabled = True
            Else
                btnNew.Enabled = False
                btnUpdate.Enabled = False
                btnDelete.Enabled = False
            End If
        Catch ex As Exception
            _MsgBox.ShowMessage("Excepción", ex.Message, frmMessage.MessageType.Error_, frmMessage.MessageButtons.Ok)
        End Try
    End Sub

    Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
        Me.Dispose()
    End Sub
#End Region

End Class
